package cn.ctvonline.android.kaopu.activity.demo;

import android.app.Activity;
import android.os.Bundle;
import android.view.KeyEvent;

import cn.ctvonline.android.kaopu.R;
import cn.ctvonline.android.kaopu.base.util.ToastUtil;
import cn.ctvonline.android.kaopu.support.SwipeHelper;
import cn.ctvonline.android.kaopu.widget.layout.SwipeLayout;

/**
 * Created by dujian on 15/12/22.
 */
public class ActivitySwiperDemo extends Activity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_blk);
        SwipeHelper.getInstance().replaceSwipe(this, new SwipeLayout.OnCloseToBorderListener() {
            @Override
            public void onCloseToBorder() {
                onBackPressed();
            }
        });
    }

    protected String generatePageName() {
        return "pageName is ActivitySwiperDemo";
    }

    @Override
    public void onBackPressed() {
        ToastUtil.show(getApplicationContext(), "finished");
        super.onBackPressed();
        finish();
        overridePendingTransition(0, 0);
    }

    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        if (keyCode == KeyEvent.KEYCODE_BACK) {
            onBackPressed();
            return true;
        }
        return super.onKeyDown(keyCode, event);
    }
}
